<?php
/**
 * Save form valuers in database
 *
 * Structure declaration example :
 *
 * <onSuccess>
 *      <action type="Save">
 *          <param name="label">Message from {field1}</param>
 *      </action>
 * </onSuccess>
 */
class m_form_plugins_success_Save extends m_form_extends_SuccessAction
{
    public function execute()
    {
        $record = m_form_documents_Record::createNew();

        $label = $this->getParameter('label', $this->getStructure()->getLabel());

        $record ->setPublicationstatus('NEW')
                ->setLang($this->getStructure()->getLang())
                ->setStructureId($this->getStructureId())
                ->setFormValues($this->getFormValues())
                ->setAuthor($this->getStructure()->getLabel()." form")
                ->setLabel($label)
                ->save();

        $this->getStructure()->addRecords($record)->save();

        return true;
    }
}